home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Comms Spectacular / MacTCP / TurboTCP / Aliases / Terminal pane / CTerminalPane.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-10  |  3.0 KB  |  125 lines  |  [TEXT/KAHL]

  1. /*
  2. ** CTerminalPane.h
  3. **
  4. **    TerminalPane library
  5. **    Terminal display pane
  6. **
  7. **    Copyright © 1993, FrostByte Design / Eric Scouten
  8. **
  9. */
  10.  
  11.  
  12. #pragma once
  13. #include <CPanorama.h>
  14.  
  15.  
  16. /*
  17. ** These constants define the terminal size. You may change them here. With a little
  18. ** work, these parameters could be changed on the fly. But I haven’t been so ambitious. :-P
  19. */
  20.  
  21. #define maxX                80                    // width of screen
  22. #define maxY                24                    // height of screen
  23.  
  24. #define pixelsX                6                    // default font char width (Monaco 9)
  25. #define pixelsY                11                    // default font char height
  26.  
  27. #define offsetX                4                    // horizontal offset from screen edge
  28. #define offsetY                4                    // vertical offset from screen edge
  29.  
  30. #define sizeX                488                    // 80 columns * 6 pixels + 8 margin
  31. #define sizeY                272                    // 24 rows * 11 pixels + 8 margin
  32.  
  33.  
  34. // define the characters we will recognize
  35.  
  36. #ifndef _ASCII
  37. enum {                                        // standard ASCII keycodes
  38.     charNUL = 0,
  39.     charBEL = 7,
  40.     charBS,
  41.     charHT,
  42.     charLF,
  43.     charVT,
  44.     charFF,
  45.     charCR,
  46.     charDEL = 127
  47. };
  48. #define _ASCII 1
  49. #endif
  50.  
  51.  
  52. /*______________________________________________________________________
  53. **
  54. ** CTerminalPane
  55. **
  56. **    This class provides a rudimentary terminal emulator. It’s nothing
  57. **    fancy or snazzy. It doesn’t do VT100; it doesn’t do scrollback;
  58. **    it doesn’t handle any kind of formatting.
  59. **
  60. */
  61.  
  62. class CTerminalPane : public CPanorama {
  63.  
  64. protected:
  65.     char        theScreen[maxY][maxX];                // contents of the screen
  66.     short    theColumn;                        // terminal cursor column number
  67.     short    theLine;                            // terminal cursor line number
  68.     Boolean    blinkCursor;                        // cursor blinking is enabled
  69.     Boolean    cursorVis;                        // cursor is inverted
  70.     short    lastCursorCol;                        // position of displayed cursor
  71.     short    lastCursorLine;
  72.     long        lastCursorTick;                        // time at last cursor flash
  73.  
  74.     
  75.     // contruction/destruction
  76.     
  77. public:
  78.     void ITerminalPane (CView *anEnclosure, CBureaucrat *aSupervisor,
  79.                     short aWidth, short aHeight, short aHEncl, short aVEncl,
  80.                     SizingOption aHSizing, SizingOption aVSizing);
  81.  
  82.  
  83.     // drawing
  84.     
  85.     virtual void Draw (Rect *area);
  86.     
  87.     
  88.     // blinking cursor support
  89.     
  90.     virtual void Dawdle (long *maxSleep);
  91.     virtual Boolean BecomeGopher (Boolean fBecoming);
  92.     virtual void SetBlinking (Boolean blinkMode);
  93.  
  94.  
  95.     // scrolling
  96.     
  97.     virtual void ScrollToSelection (void);
  98.     
  99.     
  100.     // terminal emulation methods
  101.     
  102.     virtual void DoClearScreen (void);
  103.     virtual void DoWriteChar (char theChar);
  104.     virtual void DoWriteStr (char *theStr);
  105.     virtual void DoWriteBfr (char *theStr, short theSize);
  106.     virtual void DoWriteCharNum (char theChar, char leftBracket, char rightBracket);
  107.     virtual void DoEraseChar (void);
  108.     virtual void DoEraseLine (void);
  109.     
  110.     
  111.     // private screen handling methods
  112.     
  113. protected:
  114.     virtual void ClearToEOL (short col, short line);
  115.     virtual void ClearToEOS (short col, short line);
  116.     virtual void ScrollTerm (void);
  117.     virtual void InvalCharRect (short left, short top,
  118.                     short right, short bottom);
  119.     virtual void CursorMoved (void);
  120.     virtual void CalcCharRect (short left, short top, short right,
  121.                     short bottom, LongRect *theRect);
  122.     virtual void InvertCursor (short col, short line);
  123.  
  124. };
  125.